#include<bits/stdc++.h>
using std::cin;
using std::cout;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using pii = std::pair<int, int>;
#define TESTS int _; std::cin >> _; while(_--)
#define all(a) a.begin(), a.end()
#define pb push_back
#define fi first
#define se second
#define SUM(v) std::accumulate(all(v), 0LL);
#define MIN(v) *std::min_element(all(v));
#define MAX(v) *std::max_element(all(v));
#define UNIQUE(v) std::sort(all(v)), v.erase(std::unique(all(v), v.end()));


constexpr i64 inf = 1E18, Md3 = 998244353, Md7 = 1e9 + 7;
//std::mt19937 rng {std::chrono::steady_clock::now().time_since_epoch().count()};

int main() {
	
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);


	int n, q;
	std::cin >> n >> q;
	std::string s;
	std::cin >> s;
	auto check = [&](int x) -> int {
		return x >= 0 && x + 2 < n && s[x] == 'A' && s[x + 1] == 'B' && s[x + 2] == 'C';
	};
	int ans = 0;
	for(int i = 0; i < n; i++) {
		ans += check(i);
	}
	for(int i = 0; i < q; i++) {
		int x;
		char c;
		std::cin >> x >> c;
		x--;
		for(int j = x - 2; j <= x + 2; j++) {
			ans -= check(j);
		}
		s[x] = c;
		for(int j = x - 2; j <= x + 2; j++) {
			ans += check(j);
		}
		std::cout << ans << "\n";
	}
	

	return 0;
}